<script setup lang="ts">
import {useUserStore} from "@/store/user";
import {reqLogout} from "@/api/user";

const userStore = useUserStore()
const back = () => {
  uni.navigateBack({
    delta: 1
  })
}

const logout = async () => {
  await reqLogout().then((res: any) => {
    if (res.code == 200) {
      userStore.logout()
    }
  })
}

const navTo =(url:String) => {
  uni.navigateTo({
    url: url
  })
}
</script>

<template>
  <view class="bar"></view>

  <view class="container">
    <view style="display: flex">
      <u-icon name="arrow-left" color="#909399" size="28" style="margin: 15rpx" @click="back()"></u-icon>
      <h2 style="margin: 20rpx">设置</h2>
    </view>
    <u-cell-group>
      <u-cell title="收货地址" class="text" value="管理" @click="navTo('/pages/user/setting/address/address')" :isLink="true"></u-cell>
      <u-cell title="修改密码" class="text" value="修改" @click="navTo('/pages/user/setting/modfyPassword/modfyPassword')" :isLink="true"></u-cell>
    </u-cell-group>

    <view>
      <u-button type="error" v-if="userStore.token" style="margin-top: 35rpx;width: 95vw" :hairline="false"
                text="退出登录" @click="logout()"></u-button>
    </view>

  </view>
</template>

<style scoped lang="scss">
.text {
  font-size: 35rpx;
  font-weight: 700;
}
</style>
